<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core"%>
<%@ page language="java" contentType="text/html; charset=UTF-8"
	pageEncoding="UTF-8"%>
<!DOCTYPE>
<html>

<head lang="en">
<meta charset="UTF-8">
<title>有间花店 | 后台管理</title>
<link rel="shortcut icon" type="image/x-icon" href="img/favicon.ico">
<link href="css/bootstrap.min.css" rel="stylesheet">

<script src="js/html5shiv.js"></script>
<script src="js/respond.min.js"></script>
<!-- 引入css样式-->
<link rel="stylesheet" type="text/css" href="css/admin.css"
	media="screen">
<script src="http://libs.baidu.com/jquery/2.1.4/jquery.min.js"></script>
<script src="js/bootstrap.min.js"></script>
<script src="js/admin.js"></script>

<style type="text/css">
a:focus, a:hover {
	text-decoration: none;
}

.panel-body {
	text-align: left;
}

textarea {
	resize: none;
}

#mytable th, #mytable td {
	text-align: center;
	vertical-align: middle;
	font-size: 14px;
}
</style>
</head>

<body>

	<div class="wrap">
		<!-- 左边内容 -->
		<jsp:include page="/admin_menu.jsp"></jsp:include>


		<!-- 右边内容 -->
		<div id="right" class="tab-content right">

			<!--模块四 会员管理-->
			<div>
				<!-- 用户信息查询框-->
				<div class="panel panel-info">
					<div class="panel-heading">位置：会员管理</div>
					<div class="panel-body">
						<!--查询按钮及输入框-->
						<form class="form-inline">

							<!-- 下拉选择框-->
							<input type="hidden"id="hidden" value="${select}">
							<select class="form-control" id="select" name="select">
								<option name="all" value="all">请选择查询方式</option>
								<option name="uid" value="uid">用户编号</option>
								<option name="username" value="username">用户名</option>
								<option name="sex" value="sex">性别</option>
								<option name="name" value="name">姓名</option>
							</select>
							<div class="form-group">
								<input type="text" class="form-control" id="exampleInputEmail3"name="exampleInputEmail3" value="${exampleInputEmail3}" placeholder="请输入查询信息" >
							</div>

							<!-- 查询按钮-->
							<button type="button" id="btn_select"onclick="selectUid()" class="btn btn-default">查询</button>
						</form>
					</div>
				</div>
				<!-- 用户信息表格，bootstrap自适应表格-->
				<div class="table-responsive">
					<table class="table" id="mytable">
						<tr>
							<th>用户编号</th>
							<th>用户名</th>
							<th>性别</th>
							<th>姓名</th>
							<th>邮箱</th>
							<th>手机号码</th>
							<th>出生日期</th>
							<th>操作</th>
						</tr>
						<c:choose>
							<c:when test="${!empty USERS}">
								<c:forEach var="user" items="${USERS}">
									<tr>
										<th class="spec">${user.uid}</th>
										<td>${user.username}</td>
										<td>${user.sex}</td>
										<td>${user.name}</td>
										<td>${user.email}</td>
										<td>${user.telephone}</td>
										<td>${user.birthday}</td>
										<c:if test="${user.stop==0}">
											<td>
												<a href="/updateUserStop.do?uid=${user.uid}&&stop=${user.stop}"><button style="width: auto">禁止</button></a>
											</td>
										</c:if>
										<c:if test="${user.stop!=0}">
											<td>
												<a href="/updateUserStop.do?uid=${user.uid}&&stop=${user.stop}"><button>恢复</button></a>
											</td>
										</c:if>
									</tr>
								</c:forEach>
							</c:when>
							<c:otherwise>
								暂无会户
							</c:otherwise>
						</c:choose>

					</table>
					<!-- footer-->

					<div class="footer">
						<c:if test="${PAGE.isFirstPage == true}">
							<a class="btn btn-info" role="button">首页</a>
						</c:if>
						<c:if test="${PAGE.isFirstPage == false}">
							<button class="btn btn-info" onclick="herad()">首页</button>
						</c:if>
						<c:if test="${PAGE.hasPreviousPage == true}">
							<button class="btn btn-info"
								 onclick="shangyiye()">上一页</button>
						</c:if>
						<c:if test="${PAGE.hasPreviousPage == false}">
							<a class="btn btn-info" role="button">上一页</a>
						</c:if>
						<c:if test="${PAGE.hasNextPage == true}">
							<button class="btn btn-info"
								 onclick="xiayiye()">下一页</button>
						</c:if>
						<c:if test="${PAGE.hasNextPage == false}">
							<a class="btn btn-info" role="button">下一页</a>
						</c:if>
						<c:if test="${PAGE.isLastPage == true}">
							<a class="btn btn-info" role="button">尾页</a>
						</c:if>
						<c:if test="${PAGE.isLastPage == false}">
							<button class="btn btn-info" onclick="lastPage()">尾页</button>
						</c:if>
						<label for="pageNum">跳转</label> <input type="text" id="pageNum"
							value="${PAGE.pageNum}" style="width: 50px;"> <label
							for="pageNum">页，共${PAGE.pageNum}/${PAGE.pages}页</label>
						<button class="btn btn-default"  type="submit" onclick="jumpPage()">确定</button>
					</div>
				</div>

				<script type="text/javascript">
					function jumpPage(){
						var select=$("#select").val();
						var exampleInputEmail3=$("#exampleInputEmail3").val();

						var pageNum = document.getElementById("pageNum").value
						var url = "/selectUserBywz.do?startPage=" + pageNum+"&&select="+select+"&&exampleInputEmail3="+exampleInputEmail3;
						window.location.href = url;
					}

				</script>
				<script>


					function selectUid() {

						var select=$("#select").val();
						var exampleInputEmail3=$("#exampleInputEmail3").val();

						if($("#exampleInputEmail3").val()==null|| $("#exampleInputEmail3").val() == ""){
							location.href="/selectUserBywz.do?startPage=${PAGE.prePage}&&select="+select+"&&exampleInputEmail3="+exampleInputEmail3;
							return true;
						}

						if($("#select").val()=="uid"&&$("#exampleInputEmail3").val()!=null&&$("#exampleInputEmail3").val()!=""){
							var reg=/^\+?[1-9][0-9]*$/;

							if (!reg.test(($("#exampleInputEmail3").val()))){
								alert("查询编号请输入数字");
								return false;
							}else {
								location.href="/selectUserBywz.do?startPage=${PAGE.prePage}&&select="+select+"&&exampleInputEmail3="+exampleInputEmail3;
								return true;
							}

						}else {
							location.href="/selectUserBywz.do?startPage=${PAGE.prePage}&&select="+select+"&&exampleInputEmail3="+exampleInputEmail3;
							return true;
						}




					}


				</script>
				<script>

					function shangyiye() {
						var select=$("#select").val();
						var exampleInputEmail3=$("#exampleInputEmail3").val();
						location.href="/selectUserBywz.do?startPage=${PAGE.prePage}&&select="+select+"&&exampleInputEmail3="+exampleInputEmail3;
					}

					function xiayiye() {
						var select=$("#select").val();
						var exampleInputEmail3=$("#exampleInputEmail3").val();
						location.href="/selectUserBywz.do?startPage=${PAGE.nextPage}&&select="+select+"&&exampleInputEmail3="+exampleInputEmail3;
					}
					
					function lastPage() {
						var select=$("#select").val();
						var exampleInputEmail3=$("#exampleInputEmail3").val();
						location.href="/selectUserBywz.do?startPage=${PAGE.pages}&&select="+select+"&&exampleInputEmail3="+exampleInputEmail3;

					}
					function herad() {
						var select=$("#select").val();
						var exampleInputEmail3=$("#exampleInputEmail3").val();
						location.href="/selectUserBywz.do?startPage=1&&select="+select+"&&exampleInputEmail3="+exampleInputEmail3;
					}

				</script>
				<script>

						var select = $("#hidden").val();
						switch (select) {
							case "all": $("option[name='all']").attr("selected","selected"),$("#exampleInputEmail3").val(null);break;
							case "uid": $("option[name='uid']").attr("selected","selected");break;
							case "sex": $("option[name='sex']").attr("selected","selected");break;
							case "username": $("option[name='username']").attr("selected","selected");break;
							case "name": $("option[name='name']").attr("selected","selected");break;
							default : $("option[name='all']").attr("selected","selected");

						}




				</script>



			</div>


		</div>
	</div>
</body>

</html>